package com.hk.pinda.authority.config;

import com.hk.pinda.authority.biz.service.common.OptLogService;
import com.hk.pinda.log.entity.OptLogDTO;
import com.hk.pinda.log.event.SysLogListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.function.Consumer;

/**
 *
 * 系统操作日志配置类
 *
 */
@EnableAsync
@Configuration
public class SysLogConfiguration {


    /**
     *
     *  创建日志记录的监听器
     *
     */
    @Bean
    public SysLogListener sysLogListener(OptLogService optLogService){

        Consumer<OptLogDTO> consumer = (optLog) -> optLogService.save(optLog);

        return new SysLogListener(consumer);
    }



}
